       IDENTIFICATION DIVISION.
       PROGRAM-ID. rescheck.
      *  To compile: cobc -g -o .\object -t .\lst -I .\copy -ext sl -ext fd rescheck.cbl
      *  To run:     rescheck is a subprogram, called by resmain.cbl
      *
       ENVIRONMENT DIVISION. 
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
      *
           COPY "reswords.sl".
      *
       DATA DIVISION.
       FILE SECTION.
      *
       COPY "reswords.fd".
      *
       WORKING-STORAGE SECTION.
       01 reswords-ws-variables.
         05 reswords-stat           PIC XX.
           88 end-of-reswords                 VALUE "10".
           88 reswords-not-found              VALUE "35".
         05 dummy                        PIC X.
      *
       LINKAGE SECTION.                    
       01 checkword                    PIC X(32).
       01 checkword-status             PIC X.
       01 checkword-error-msg          PIC X(32).
      *
       SCREEN SECTION.
      *
       01  rescheck-intro.
           05 VALUE "Rescheck"                   BLANK SCREEN
                                                 LINE 02 COL 20.
           05  VALUE "This program checks to see if a word passed" 
                                                 LINE 04 COL 20.
           05  VALUE "through linkage is a reserved word, and returns" 
                                                 LINE 05 COL 20.
           05  VALUE "a status (0=NO, 1=YES) to the calling program." 
                                                 LINE 06 COL 20.
      *
       01  rescheck-msg.
           05 VALUE "Checking : "                LINE 10 COL 10.
           05 rescheck-checkword                     
                  PIC X(35) FROM checkword       LINE 10 COL 21.
           05 VALUE "Returning: "                LINE 11 COL 10.
           05 rescheck-checkword-status  
                  FROM checkword-status          LINE 11 COL 21.
      *
       PROCEDURE DIVISION USING checkword, 
                                checkword-status,
                                checkword-error-msg.  
       main. 
           MOVE FUNCTION UPPER-CASE (checkword) to reserved-word.

           PERFORM open-reswords.
           PERFORM validate-checkword.
           DISPLAY rescheck-intro.
           DISPLAY rescheck-msg.
           CLOSE reswords.
           PERFORM exit-rescheck.
      *
       open-reswords.
           OPEN INPUT reswords.
       
           IF reswords-not-found
             MOVE "reswords.dat not found" TO checkword-error-msg
             PERFORM exit-rescheck 
           END-IF.
      *
       validate-checkword.          
           READ reswords 
             INVALID KEY 
                 MOVE 0 TO checkword-status
             NOT INVALID KEY 
                 MOVE 1 TO checkword-status
           END-READ.
      *
       show-msg-screen.
      *
       
       exit-rescheck.
           GOBACK.